import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { useI18n } from "@/hooks/web/useI18n";

const { t } = useI18n();
//表格数据
export const columnsModelstab: BasicColumn[] = [
  {
    title: t('sys.informaionMatchaing.columns.title'),
    dataIndex: 'title',
    width: 120,
  },
  {
    title: t('sys.configuration.describe'),
    dataIndex: 'remark',
    width: 120,
    customRender: ({ text }: { text: string }) => {
      return h(
        Tooltip,
        {
          title: text,
        },
        [
          h(
            'span',
            {
              style: {
                display: 'inline-block',
                width: '100%',
                height: 'auto',
                overflow: 'hidden',
                textOverflow: 'ellipsis',
                whiteSpace: 'nowrap',
              },
            },
            text,
          ),
        ],
      );
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.status'),
    dataIndex: 'status',
    width: 120,
    customRender: ({ record }: { record: Recordable }) => {
      if (record.status === t('sys.configuration.inProgress')) {
        if (record.status1 !== t('sys.configuration.taskSucces')) {
          return `一阶段状态 ${record.status1}`;
        } else {
          return `二阶段状态 ${record.status2}`;
        }
      }
      return record.status;
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.type'),
    dataIndex: 'type',
    width: 80,
    customRender: ({ record }: { record: Recordable }) => {
      return record.type == 'orientation' ? t('sys.informaionMatchaing.columns.orientation') : t('sys.informaionMatchaing.columns.match');
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.success'),
    dataIndex: 'success',
    width: 80,
    customRender: ({ record }: { record: Recordable }) => {
      const success = record.success ?? '-';
      const maxNum = record.maxNum ?? '-';
      return `${success}/${maxNum}`;
    },
  },
];

// 详情表格数据
export const columnsModels: BasicColumn[] = [
  {
    title: t('sys.informaionMatchaing.columns.url'),
    dataIndex: 'url',
    width: 120,
    customRender: ({ text, record }) => {
      return h(
        'a',
        {
          href: text,
          target: '_blank', // 在新标签页中打开链接
        },
        text,
      );
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.title'),
    dataIndex: 'title',
    width: 120,
  },
  {
    title: t('sys.informaionMatchaing.columns.matching'),
    dataIndex: 'matching',
    width: 60,
  },
];
